package org.SoccerTournament.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Table;
import javax.persistence.Version;


@MappedSuperclass
@Entity
@Table(name="Users")
public class User  implements Serializable {
	
	private Long userId;
	
	public User(){
		super();
	}
	
	public User(String userName, String password, String name, String lastName,String nickName) {
		super();
		this.userName = userName;
		this.password = password;
		this.name = name;
		this.lastName = lastName;
		this.nickName = nickName;
	}
	
	private static final long serialVersionUID = 1L;

	private String userName;
	
	/*Hay que encriptarla*/
	private String password;
	
	private String name;
	
	private String lastName;
	
	private String nickName;
	
	private Integer version;
	

	@Id
	@GeneratedValue
	@Column(name="userId")
	public Long getId() {
		return userId;
	}
	
	@Version
	@Column(name="OPTLOCK")
	public Integer getVersion() {
		return version;
	}

	
	
	@Column(name="UserName")
	public String getUserName() {
		return userName;
	}


	@Column(name="password")
	public String getPassword() {
		return password;
	}


	@Column(name="name")
	public String getName() {
		return name;
	}


	@Column(name="lastName")
	public String getLastName() {
		return lastName;
	}


	@Column(name="nickName")
	public String getNickName() {
		return nickName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}
	
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	
	public void setNickName(String nickName) {
		this.nickName = nickName;
	}
	
	public void setVersion(Integer version) {
		this.version = version;
	}
	
	public void setPassword(String password) {
		this.password = password;
	}
	
	public void setId(Long id) {
		this.userId = id;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public boolean equals(Object other) {
		if (this == other)
			return true;
		
		if (userId == null)
			return false;
		
		if (!(other instanceof User))
			return false;
		
		return this.getId().equals(((User) other).getId());
	}
	
	public int hashCode() {
		return this.getId() == null ? System.identityHashCode(this) : this.getId().hashCode();
	}
}